-
Notifications
You must be signed in to change notification settings - Fork 3
[refactor] 재연결 로직 리팩토링 #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| Long joinedRoomId = userRoomRepository.getRoomId(userId); | ||
|
|
||
| if (joinedRoomId != null && !room.getId().equals(joinedRoomId)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[L4-변경제안]
Objects.equals()사용하면 의도가 명확해보여서 좋을 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
room 내부의 메서드로 분리하면 좋을 것 같습니다 !
# Conflicts: # backend/src/main/java/io/f1/backend/domain/game/app/GameService.java
| return; | ||
| } | ||
|
|
||
| if (room.getState().equals(RoomState.PLAYING)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
room.isPlaying() 메서드로 대체할 수 있을 것 같습니다 !
| } | ||
|
|
||
| /* 재연결 */ | ||
| if (room.getPlayerState(userId).equals(ConnectionState.DISCONNECTED)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
room의 메서드로 분리하는게 좋을 것 같습니다 !
|
|
||
| public void cancelDisconnectTask(Long userId) { | ||
| ScheduledFuture<?> task = disconnectTasks.remove(userId); | ||
| if (task != null && !task.isDone()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위의 조건문과 같은 코드가 반복됩니다 ! 메서드로 분리하면 좋을 것 같습니다
silver-eunjoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이미 구현된 이렇게 복잡한 로직을 다시 리팩토링하신 게 대단하셔요.. 확인했습니다 !! 고생하셨어요 :)
| roomService.exitRoom(roomId, sessionId, principal); | ||
| roomService.exitRoom(roomId, principal); | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.printStackTrace() 보다 로깅을 사용하는 것이 좋아보입니다 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요부분 로깅은 안봐도되는 부분이라서 지웠어야하는건데 안지웠네욥 ..ㅎㅎ 삭제했습니다!
| cancelIfRunning(task); | ||
| } | ||
|
|
||
| private static void cancelIfRunning(ScheduledFuture<?> future) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static 키워드는 없어도 될 것 같습니다 !
|
|
||
| if (room.getRoomSetting().locked() | ||
| && !room.getRoomSetting().password().equals(request.password())) { | ||
| && !room.getRoomSetting().password().equals(request.password())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
room 내부 메서드로 분리하는게 좋아보입니다 !
jiwon1217
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 ! 리팩토링을 거치니 확실히 재연결 로직이 간결해보입니다 !
LimKangHyun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
🛰️ Issue Number
🪐 작업 내용
disconnected 이벤트 리스너
disconnect되었을때 플레이어 상태disconnected로 변경exit)→ 입장하셨습니다.(initializeRoomSocket)userRoomRepository
userId,roomId매핑 정보를 담고 있는userRoomRepository생성enterRoom
disconnect이벤트 리스너를 동작시키지 않고enterRoom요청할때 (브라우저 새로 켜서 접속)room에서disconnectedexitinitializeRoomSocket
playerMap에 없는 유저 접근시enterRoom로직 실행 안한것이므로 예외처리connected로 상태 값 변경 후reconnect용 응답 보내기DisconnectTaskManager를 생성해서roomService,handleDisconnectedListener에서 참조📚 Reference
✅ Check List